/*************************************************************************
 * Nuvoton Electronics Corporation confidential
 *
 * Copyright (c) 2008 by Nuvoton Electronics Corporation
 * All rights reserved
 *
 * FILENAME
 *     gpio_test.c
 *
 * VERSION
 *     1.0
 *
 * DESCRIPTION
 *     NUC900 GPIO library example program
 *
 * HISTORY
 *     2008.06.24       Created
 *
 * REMARK
 *     None
 **************************************************************************/
#include "wblib.h"
#include "nuc900_gpio.h"

INT32 GpioCallback(UINT32 status, UINT32 userData)
{
    /* To do */
    return 0;
}

INT main(VOID)
{

#if 1

	rCLKEN |= 2;
	rMFSEL |= 0x800000;
	rACTL_CON |= 0x104;

	while(1) {
		rACTL_ACCON = 0;
		rACTL_ACCON = 2;	
	}


#else	
	
    GPIO_InitFunction(FUNC_GPIO);
    
    GPIO_Open(GPIOC, DIR_INPUT, PULL_UP);
    GPIO_Set(GPIOC, 0xFFF);
    GPIO_Clr(GPIOC, 0xFFF);
    GPIO_Close(GPIOC);
    
    
    GPIO_OpenBit(GPIOD, BIT3, DIR_OUTPUT, NO_PULL_UP);
	while(1) {
    	rGPIOD_DATAOUT = 8;
    	rGPIOD_DATAOUT = 0;
    	rGPIOD_DATAOUT = 8;
    	rGPIOD_DATAOUT = 0;
    	rGPIOD_DATAOUT = 8;
    	rGPIOD_DATAOUT = 0;
    	rGPIOD_DATAOUT = 8;
    	rGPIOD_DATAOUT = 0;
    	rGPIOD_DATAOUT = 8;
    	rGPIOD_DATAOUT = 0;    	    	    	    	
    }
    GPIO_CloseBit(GPIOD, BIT3);
    
    GPIO_InitFunction(FUNC_NIRQ0_3);
    GPIO_OpenBit(GPIOH, BIT0, DIR_INPUT, PULL_UP);
    GPIO_SetTriggerType(NIRQ0, RISING);
    GPIO_EnableInt(NIRQ0, (GPIO_CALLBACK)GpioCallback, 0);
    GPIO_CloseBit(GPIOH, BIT0);
#endif

    return 0;
}